package com.vipbbo.spring.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * 账户接口实现
 *
 * @author paidaxing
 */
//@Service("accountByAnnotationService")
public class AccountByAnnotationServiceImpl implements AccountByAnnotationService {


	@Autowired
	private JdbcTemplate jdbcTemplate;
	private static String insertSql = "insert into account(balance) values (100)";

	@Override
	public void save() throws RuntimeException {

		try {
			System.out.println("======开始执行sql======");
			jdbcTemplate.execute(insertSql);
			System.out.println("======sql执行结束======");
			System.out.println("======准备抛出异常======");
			throw new RuntimeException("手动抛出异常");
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}

}
